<%@page pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="f" uri="http://www.slim3.org/functions"%>

<%@ page import="java.util.ArrayList" %>
<%@ page import="slim3.demo.controller.six.FlightBean_Intl" %>
<%@ page import="slim3.demo.controller.six.AirportBean" %>

<html>
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<meta content="120; url=http://apbfour.appspot.com/six/arrivalLogo" http-equiv="refresh">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>松山機場 - 國際線今日到站客機</title>
<link rel="stylesheet" type="text/css" href="blueprint/screen.css" />
<link href="tablecloth/tablecloth_smallfont.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="tablecloth/tablecloth.js"></script>

<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="apple-touch-icon.png"/>
<link rel="apple-touch-startup-image" href="apple-touch-icon.png" />

<script type="text/javascript" src="./jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
// When document is ready: this gets fired before body onload :)
$(document).ready(function(){
	// Write on keyup event of keyword input element
	$("#kwd_search").keyup(function(){
		// When value of the input is not blank
		if( $(this).val() != "")
		{
			// Show only matching TR, hide rest of them
			$("#my-table tbody>tr").hide();
			$("#my-table td:contains-ci('" + $(this).val() + "')").parent("tr").show();
		}
		else
		{
			// When there is no input or clean again, show everything back
			$("#my-table tbody>tr").show();
		}
	});
});
// jQuery expression for case-insensitive filter
$.extend($.expr[":"], 
{
    "contains-ci": function(elem, i, match, array) 
	{
		return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
	}
});

</script>

<style>

body{
	margin:0;
	padding:0;
	background:#f1f1f1;
	font:200% "標楷體", Arial, Helvetica, sans-serif; 
	color:#555;
	line-height:150%;
	text-align:left;
}
a{
	text-decoration:none;
	color:#057fac;
}
a:hover{
	text-decoration:none;
	color:#999;
}
h1{
	font-size:140%;
	margin:0 20px;
	line-height:80px;	
}
h2{
	font-size:120%;
}
#container{
	margin:0 auto;
	width:680px;
	background:#fff;
	padding-bottom:20px;
}
#content{margin:0 20px;}
p.sig{	
	margin:0 auto;
	width:680px;
	padding:1em 0;
}
form{
	margin:1em 0;
	padding:.2em 20px;
	background:#eee;
}
</style>


<script type="text/javascript">
<!--
function reload(condition) {
	if (condition == "yes") {
		document.location.reload(true);
	}
}
//-->
</script>


<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33867276-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>


</head>
<body>
<script type="text/javascript" src="wz_tooltip/wz_tooltip.js"></script>

<center>
  <p class="notice"><font color="#CC6600" size="+1">此網頁每隔2分鐘將自動重新整理&nbsp;&nbsp;&nbsp;&nbsp;<a href="list"><font color="0000FF">主目錄</font></a></font></p><br>
  <%
	String year = (String) request.getAttribute("year");
	String month = (String) request.getAttribute("month");
	String day = (String) request.getAttribute("day");
	String hour = (String) request.getAttribute("hour");
	String minute = (String) request.getAttribute("minute");
	String second = (String) request.getAttribute("second");

	//ArrayList<AirportBean> airportlist = (ArrayList<AirportBean>) request.getAttribute("airportlist");
  %>
    中華民國<%=year %>年<%=month %>月<%=day %>日<%=hour %>時<%=minute %>分<%=second %>秒<br />
    松山機場國際線今日到站客機

<p><font color="#0000FF" size="+1" face="Verdana">即時搜尋：<input type="text" id="kwd_search" value=""/></font></p>
 
</center>

	<table id="my-table" cellspacing="0" cellpadding="0">
	<thead>
		<tr>			
			<th>起飛地</th>
			<th>航空公司</th>
			<th>編號</th>
			<th>表定抵達</th>
			<th>實際抵達</th>
			<th>狀態</th>
		</tr>
	</thead>
		
		<%
			ArrayList<FlightBean_Intl> beans = (ArrayList<FlightBean_Intl>) request.getAttribute("flightlist");
			String temp = "";
		%>
		<%
			if (beans.size()==0) {
		%>		
				</table><font color="#FF0000" size="+2">請稍等一下，為您重新讀取松山機場資料庫！</font>
				<script type="text/javascript" language="JavaScript">
         			reload("yes");
      			</script>
		<%
			} else {
		%>
	<tbody>
		<%
			for (int i=0; i<beans.size(); i++) {
		%>
			<tr>
				<td>
					<%
						if (beans.get(i).getOrigin().equals("TSN")) {
							temp = "天津";
						} else if (beans.get(i).getOrigin().equals("TYN")) {
							temp = "太原";
						} else if (beans.get(i).getOrigin().equals("HFE")) {
							temp = "合肥";
						} else if (beans.get(i).getOrigin().equals("CTU")) {
							temp = "成都";
						} else if (beans.get(i).getOrigin().equals("HND")) {
							temp = "羽田";
						} else if (beans.get(i).getOrigin().equals("HGH")) {
							temp = "杭州";
						} else if (beans.get(i).getOrigin().equals("WUH")) {
							temp = "武漢";
						} else if (beans.get(i).getOrigin().equals("GMP")) {
							temp = "金浦";
						} else if (beans.get(i).getOrigin().equals("NNG")) {
							temp = "南寧";
						} else if (beans.get(i).getOrigin().equals("SHA")) {
							temp = "虹橋";
						} else if (beans.get(i).getOrigin().equals("CKG")) {
							temp = "重慶";
						} else if (beans.get(i).getOrigin().equals("PVG")) {
							temp = "浦東";
						} else if (beans.get(i).getOrigin().equals("HAK")) {
							temp = "海口";
						} else if (beans.get(i).getOrigin().equals("XMN")) {
							temp = "廈門";
						} else if (beans.get(i).getOrigin().equals("WNZ")) {
							temp = "溫州";
						} else if (beans.get(i).getOrigin().equals("FOC")) {
							temp = "福州";
						} else {
							temp = beans.get(i).getOrigin();
						}
					%>
					<%=temp %>
				</td>
								
				<td>
					<%
						String airline = "";
						if (beans.get(i).getAirline().equals("FM")) {
							temp = "./logos/fm.gif";
							airline = "中國上海航空(上航)";
						} else if (beans.get(i).getAirline().equals("NH")) {
							temp = "./logos/nh.png";
							airline = "全日本空輸(全日空)";
						} else if (beans.get(i).getAirline().equals("CA")) {
							temp = "./logos/ca.png";
							airline = "中國國際航空(國航)";
						} else if (beans.get(i).getAirline().equals("3U")) {
							temp = "./logos/3u.gif";
							airline = "四川航空(川航)";
						} else if (beans.get(i).getAirline().equals("MF")) {
							temp = "./logos/mf.jpg";
							airline = "廈門航空(廈航)";
						} else if (beans.get(i).getAirline().equals("GE")) {
							temp = "./logos/ge.gif";
							airline = "復興航空(復興)";
						} else if (beans.get(i).getAirline().equals("TW")) {
							temp = "./logos/tw.png";
							airline = "德威航空(德威)";
						} else if (beans.get(i).getAirline().equals("JL")) {
							temp = "./logos/jl.png";
							airline = "日本航空(日航)";
						} else if (beans.get(i).getAirline().equals("ESR")) {
							temp = "./logos/esr.png";
							airline = "易斯達航空(易斯達)";
						} else if (beans.get(i).getAirline().equals("ZE")) {
							temp = "./logos/esr.png";
							airline = "易斯達航空(易斯達)";
						} else if (beans.get(i).getAirline().equals("MU")) {
							temp = "./logos/mu.png";
							airline = "中國東方航空(東航)";
						} else if (beans.get(i).getAirline().equals("AE")) {
							temp = "./logos/ae.png";
							airline = "華信航空(華信)";
						} else if (beans.get(i).getAirline().equals("CI")) {
							temp = "./logos/ci.gif";
							airline = "中華航空(華航)";
						} else if (beans.get(i).getAirline().equals("FE")) {
							temp = "./logos/fe.gif";
							airline = "遠東航空(遠東)";
						} else if (beans.get(i).getAirline().equals("BR")) {
							temp = "./logos/br.png";
							airline = "長榮航空(長榮)";
						} else if (beans.get(i).getAirline().equals("B7")) {
							temp = "./logos/b7.gif";
							airline = "立榮航空(立榮)";
						} else {
							temp = beans.get(i).getAirline();
							airline = beans.get(i).getAirline();
						}
					%>
					<img src="<%=temp %>" align="absmiddle" alt="<%=airline %>" onmouseover="Tip('<%=airline %>')" onmouseout="UnTip()">
				</td>
				
				<td>
					<%
						temp = beans.get(i).getAirline() + "-" + beans.get(i).getFlightNo();
					%>
						<%=temp %>
				</td>
				
				<td>
					<%
						temp = beans.get(i).getSchedTime();
						temp = temp.substring(0, 2) + ":" + temp.substring(2);
					%>
					<%
						if (beans.get(i).getActualTime().equals(beans.get(i).getSchedTime())) {
					%>
						<%=temp %>
					<%
						} else {
					%>
						<font color=#FF0000><%=temp %></font>
					<%
						}
					%>
				</td>
				
				<td>
					<%
						temp = beans.get(i).getActualTime();
						temp = temp.substring(0, 2) + ":" + temp.substring(2);
					%>
					<%
						if (beans.get(i).getActualTime().equals(beans.get(i).getSchedTime())) {
					%>
						<%=temp %>
					<%
						} else {
					%>
						<font color=#FF0000><%=temp %></font>
					<%
						}
					%>
				</td>
				
				<td>
					<%
						if (beans.get(i).getStatus().substring(4).equals("On Time")) {
							temp = "準時";
						} else if (beans.get(i).getStatus().substring(4).equals("Arrived")) {
							temp = "已到";
						} else if (beans.get(i).getStatus().substring(4).equals("Departed")) {
							temp = "已飛";
						} else if (beans.get(i).getStatus().substring(4).equals("Delayed")) {
							temp = "延誤";
						} else if (beans.get(i).getStatus().substring(4).equals("Cancel")) {
							temp = "取消";
						} else if (beans.get(i).getStatus().substring(4).equals("Boarding")) {
							temp = "登機中";
						} else if (beans.get(i).getStatus().substring(4).equals("Examining")) {
							temp = "安檢中";
						} else if (beans.get(i).getStatus().substring(4).equals("Check In")) {
							temp = "報到中";
						} else if (beans.get(i).getStatus().substring(4).equals("Extra")) {
							temp = "加班機";
						} else if (beans.get(i).getStatus().substring(4).equals("Early")) {
							temp = "提早";
						} else if (beans.get(i).getStatus().substring(4).equals("EARLY")) {
							temp = "提早";
						} else if (beans.get(i).getStatus().substring(4).equals("Divert")) {
							temp = "轉降";
						} else if (beans.get(i).getStatus().substring(4).equals("Return")) {
							temp = "返航松山";
						} else if (beans.get(i).getStatus().substring(4).equals("Retuen")) {
							temp = "返航松山";
						} else if (beans.get(i).getStatus().substring(4).equals("Charter")) {
							temp = "包機";
						} else if (beans.get(i).getStatus().substring(4).equals("Close")) {
							temp = "關場";
						} else if (beans.get(i).getStatus().substring(4).equals("LandInTaoYuan")) {
							temp = "轉降桃園";
						} else if (beans.get(i).getStatus().substring(4).equals("TEST")) {
							temp = "航班測試TEST";
						} else if (beans.get(i).getStatus().substring(4).equals("LandInGaoXiong")) {
							temp = "轉降高雄";
						} else if (beans.get(i).getStatus().substring(4).equals("LandInBeiGan")) {
							temp = "轉降北竿";
						} else if (beans.get(i).getStatus().substring(4).equals("FlyFromTaoYuan")) {
							temp = "由桃園機場搭機";
						} else if (beans.get(i).getStatus().substring(4).equals("LandInTaiZhong")) {
							temp = "轉降臺中";
						} else if (beans.get(i).getStatus().substring(4).equals("ScheduleChanged")) {
							temp = "時間更改";
						} else {
							temp = "特殊情況";
						}
					%>
					<%=temp %>
				</td>
			</tr>
		
		<%
			}
			}
		%>

	</tbody>
	</table>
		

<center>
<!--<font size="2" face="Arial" color="#777777">航班資料由<a href="http://www.tsa.gov.tw" target="_blank">松山機場</a>、<a href="http://www.uniair.com.tw" target="_blank">立榮航空</a>、<a href="http://www.tna.com.tw" target="_blank">復興航空</a>提供&nbsp;&nbsp;氣象資料由<a href="http://aoaws.caa.gov.tw/AWS/mainRight.php?lang=tw" target="_blank">航空氣象服務網</a>提供&nbsp;&nbsp;機場狀態由<a href="http://aoaws.caa.gov.tw/AWS/takeland.php?lang=tw" target="_blank">起降天氣標準</a>所提供的值自動推測</font>-->
<font size="2" face="Arial" color="#777777">航班資料由<a href="http://www.tsa.gov.tw" target="_blank">松山機場</a>提供</font>
</center>
</html>